/*
 * FileMerger.h
 *
 *  Created on: Oct 10, 2012
 *      Author: bruno
 */

#ifndef FILEMERGER_H_
#define FILEMERGER_H_

#include <iostream>
#include <vector>
#include "IDictionaryStorage.h"
#include "tools/Heap.h"
#include "../../physical_layer/file_system/TermOccurrence.h"

using physical::TermOccurrence;

typedef std::shared_ptr<IDictionaryStorage> IDS_ptr;
typedef std::shared_ptr<TermOccurrence> DICTIONARY_ENTRY;

class FileMerger {
private:
	IDS_ptr output;
	std::vector<IDS_ptr> *inputs;

public:
	FileMerger();
	virtual ~FileMerger();

	void addinput(IDS_ptr&);
	void setOutput(IDS_ptr&);
	void mergeFiles();
	void clearInputs();

};

class MergeProcessEntry {
public:
	IDS_ptr storage;
	DICTIONARY_ENTRY value;

	MergeProcessEntry() {
		storage = NULL;
	}
	MergeProcessEntry( IDS_ptr &storage, DICTIONARY_ENTRY value) {
		this->storage = storage;
		this->value = value;
	}
	MergeProcessEntry(const MergeProcessEntry& orig) {
		this->storage = orig.storage;
		this->value = orig.value;
	}
	MergeProcessEntry& operator=(const MergeProcessEntry& orig) {
		if (this != &orig) {
			this->storage = orig.storage;
			this->value = orig.value;
		}
		return *this;
	}
	virtual ~MergeProcessEntry() {
	}

};

int mergeProcessEntryComparator(MergeProcessEntry entry1,
		MergeProcessEntry entry2);

#endif /* FILEMERGER_H_ */
